package com.demo.easyexcel;

import com.alibaba.excel.EasyExcel;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
public class Excel {
    public static void main(String[] args) {
        //写操作
//        String fileName="D:\\java.xlsx";
//        EasyExcel.write(fileName,WriteData.class).sheet("学生列表").doWrite(data());


        //读操作
        String fileName="D:\\java.xlsx";
        EasyExcel.read(fileName,ReadData.class,new ExcelListener()).sheet().doRead();
    }

    public static List<WriteData> data(){
        List<WriteData> list=new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            WriteData data=new WriteData();
            data.setSno(i);
            data.setName("kyh-----"+i);
            list.add(data);
        }
        return list;
    }
}
